package com.sl.au.repository;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.UserTrajectory;
import com.sl.au.entity.Hierarchy;
public interface UserTrajectoryRepository extends JpaRepository<UserTrajectory, String> {
	@Query("select a from UserTrajectory a where a.user.hierarchy = ?1 order by a.user.id,a.trajectoryTime asc")
	List<UserTrajectory> getAllByDept(Hierarchy dept);
	
	@Query("select a from UserTrajectory a where a.user.id in ?1 order by a.user.id,a.trajectoryTime asc")
	List<UserTrajectory> getAllByUserIds(List<String> ids);

	@Query("select a from UserTrajectory a where a.user.id in ?1 and a.trajectoryTime >= ?2 and a.trajectoryTime <= ?3 order by a.user.id,a.trajectoryTime asc")
	List<UserTrajectory> getAllByUserIdsAndDate(List<String> ids, Date begin, Date end);

	@Query("select a from UserTrajectory a where a.user.id = ?1 order by a.trajectoryTime asc")
	List<UserTrajectory> getUserId(String ids);
	
}